﻿using System;

namespace ParsePtb.attr
{

    //查询 新增 修改的注解
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
    public class TableFieldAttr : Attribute
    {
        //bool是boolean 的类型
        //是否存在的字段==> 针对查询
        private bool isExist = true;

        //数据库列名
        private string columName;


        //字符串类型
        private string jdbcType;

        //默认值
        private string value;


        /*     //新增 修改 选着性操作的字段
             private bool selective;*/

        //需要自定义的数据库函数
        private bool definedFunc;

        //是否主键
        private bool primaryKey = false;


        //函数的表达式
        private string patternStr;

        //是否更新 默认为true
        private bool isUpdate = true;


        public TableFieldAttr(string columName)
        {
            this.ColumName = columName;
        }

        //字段数据库不存在
        public TableFieldAttr(bool isExist)
        {
            this.IsExist = false;
        }

        //用于查询==> exist 怎么设置都是false
        public TableFieldAttr(string columName, bool isExist)
        {
            this.ColumName = columName;
            this.IsExist = false;
        }

        //行数据列名 默认值
        public TableFieldAttr(string columName, string value)
        {
            this.ColumName = columName;
            this.Value = value;
        }


        public TableFieldAttr(string columName, string value, string jdbcType, bool definedFunc, bool primaryKey, string patternStr)
        {
            this.ColumName = columName;
            this.DefinedFunc = definedFunc;
            this.JdbcType = jdbcType;
            this.DefinedFunc = definedFunc;
            this.PrimaryKey = primaryKey;
            this.PatternStr = patternStr;
            this.Value = value;
        }

        public TableFieldAttr(string columName, string value, string jdbcType, bool definedFunc, bool primaryKey, string patternStr, bool isUpdate)
        {
            this.ColumName = columName;
            this.DefinedFunc = definedFunc;
            this.JdbcType = jdbcType;
            this.DefinedFunc = definedFunc;
            this.PrimaryKey = primaryKey;
            this.PatternStr = patternStr;
            this.Value = value;
            this.IsUpdate = isUpdate;
        }


        public bool IsExist { get => isExist; set => isExist = value; }
        public string ColumName { get => columName; set => columName = value; }
        public string JdbcType { get => jdbcType; set => jdbcType = value; }
        public string Value { get => value; set => this.value = value; }
        public bool DefinedFunc { get => definedFunc; set => definedFunc = value; }
        public bool PrimaryKey { get => primaryKey; set => primaryKey = value; }
        public string PatternStr { get => patternStr; set => patternStr = value; }
        public bool IsUpdate { get => isUpdate; set => isUpdate = value; }
    }
}
